package com.cloudbroker.bcs.common.util;

import java.lang.reflect.Field;

/**
 * Created by lili19289 on 2017/1/6.
 */
public class ExceptionMsgUtil {


    public static String getExceptionMsg(Exception e){
        String errorMsg ="";
        try {
            Class clazz = e.getClass();
            while(clazz != Throwable.class){
                clazz = clazz.getSuperclass();
            }
            Field field = clazz.getDeclaredField("detailMessage");
            field.setAccessible(true);
            errorMsg = field.get(e).toString();
        }catch (Exception e1){
            e1.printStackTrace();
        }

        return errorMsg;
    }
}
